    function chdim( x , v  , str ); 
% function chdim( x , v  , str ); 
%
% CHeck DIMension 
% x     array whose dimension want to check 
% v     vector with the dimensions must match 
% str   (optional) string labelling the array 
% 
% error message occurs if 
% lengths of v  and size(x) not equal or 
% size(x) is different from v for any element  
% no output otherwise 
% 
% Alejandro Justiniano @2004
% ajustiniano@imf.org 
% 5/27/04
v=v(:); 
ch=size( x )' ; 
if length( ch ) ~= length( v ); 
    error('Input dimension does not match the one you provided' ); 
end
if isequal( v , ch ) ~=1;  
    ind=find( (v-ch) ~= 0 ); 
    if nargin < 3 
        s='' ;
    else 
        s=['In array ',str,'  , ' ];
    end
    disp( [s,'for dimension ', num2str(ind'),' : '] );
    disp('dimension mistmatch'); 
    error('Vector does not match dimension you provided') 
end